home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 17 / AMIGAplus Sonderheft 17 (1999)(ICP)(DE)[!].iso / PD / Anwendungen / IxGuide / docs / ixclient_1.rexx < prev    next >
OS/2 REXX Batch file  |  1997-03-22  |  3KB  |  143 lines

  1. /* Sample arexx client program for iX-Guide. */
  2. /* This client receives all events available */
  3. /* from iX-Guide and prints message on every */
  4. /* event                                     */ 
  5.  
  6. if ~show('l', "rexxsupport.library") then
  7.     addlib('rexxsupport.library',0,-30,0)
  8.  
  9. OPTIONS RESULTS
  10.  
  11. /*
  12. ** Every rexx client receives pointer to iXG window as the last argument
  13. ** in form 'iXW=<address>'. That is the window the rexx client was launched
  14. ** from. You always have to pass this pointer to ADDCLIENT !
  15. */
  16.  
  17. PARSE ARG 'iXW=' windowPTR .
  18.  
  19. /*
  20. ** Port name of every rexx client should be in the following form:
  21. ** "IXCL_anythingyouwant_windowPTR"
  22. */
  23.  
  24. portname = "IXCL_demoCL1_"
  25. portname = INSERT(windowPTR,portname,LENGTH(portname))
  26.  
  27. /************************************************************************/
  28.  
  29. if show('p',portname) then exit   /* we are already running */
  30.  
  31. ADDRESS IXGUIDE
  32.  
  33. /*
  34. ** Add this client to iX-Guide and pass received window pointer
  35. */
  36.  
  37. AddClient windowPTR
  38.  
  39. /************************************************************************/
  40.  
  41. call openport(portname)
  42. setport portname KEYBOARD MOUSE MISC VGUPDATE
  43.  
  44. AllocRaster 1
  45. rp=result
  46. Refresh rp
  47.  
  48. Move rp 0 10
  49. shutdown=0
  50. yc=10
  51. do until shutdown
  52.  call waitpkt(portname)
  53.  msg = getpkt(portname)
  54.  
  55.  if msg ~= '0000 0000'x then do
  56.   cmd = getarg(msg)
  57.   
  58.   if cmd='0000 0000'x then shutdown=1  /* pointer to window is NULL */
  59.   else if cmd=windowPTR then do        /* this is message from our window */
  60.   cmd = getarg(msg,1)
  61.   
  62.   if cmd='MOUSE' then do
  63.    a1=getarg(msg,2)
  64.    a2=getarg(msg,3)
  65.    a3=getarg(msg,4)
  66.    say 'MOUSE EVENT [ROBJ='a1',X='a2',Y='a3']'
  67.    if a1=1 then do
  68.     Move rp a2 a3
  69.     SetABPen rp 2 1
  70.     Text rp 'Arexx'
  71.    end
  72.   end
  73.   
  74.   if cmd='KEYBOARD' then do
  75.    a4=getarg(msg,2)
  76.    if a4='RAWKEY' then do
  77.     a1=getarg(msg,3)
  78.     a2=getarg(msg,4)
  79.     say 'KEYBOARD EVENT Rawkey ['a1':'a2']'
  80.    end
  81.    else do
  82.     a1=getarg(msg,3)
  83.     say 'KEYBOARD EVENT Vanilla ['d2c(a1)']'
  84.     if a1=13 then do
  85.      yc=yc+10
  86.      Move rp 0 yc
  87.     end
  88.     if a1=32 then Text rp '" "'
  89.     SetABPen rp 1 0
  90.     Text rp d2c(a1)
  91.    end
  92.   end
  93.   
  94.   if cmd='VGUPDATE' then do
  95.    a1=getarg(msg,2)
  96.    a2=getarg(msg,3)
  97.    say 'VGUPDATE EVENT Left 'a1' Top 'a2
  98.   end
  99.   
  100.   if cmd='MISC' then do
  101.    a4=getarg(msg,2)
  102.    if a4='QUIT' then do
  103.     shutdown=1
  104.     say 'QUIT EVENT'
  105.    end
  106.    if a4='CLOSEWIN' then do
  107.     shutdown=1
  108.     say 'CLOSE WINDOW EVENT'
  109.    end
  110.    if a4='WINRESIZED' then
  111.    say 'WINRESIZED EVENT'
  112.    if a4='LINKREQ' then do
  113.     a5=getarg(msg,3)
  114.     say 'LINK REQUESTED Name ['a5']'
  115.    end
  116.    if a4='LINKOK' then do
  117.     a5=getarg(msg,3)
  118.     a6=getarg(msg,4)
  119.     say 'LINK SUCCEDED Database name ['a5'] Node name ['a6']'
  120.    end
  121.    if a4='LINKFAILED' then do
  122.    a5=getarg(msg,3)
  123.    a6=getarg(msg,4)
  124.    say 'LINK FAILED EVENT Database name ['a5'] Node name ['a6']'
  125.    end
  126.    if a4='ASKSCREEN' then say 'User asked for new screen'
  127.    if a4='NEWSCREEN' then do say 'Screen changed !'; shutdown=1; end
  128.    if a4='OLDSCREEN' then say 'New screen failed...'
  129.   end
  130.   
  131.   end
  132.   call reply(msg,0)
  133.  end
  134. end
  135.  
  136. /*
  137. ** Clean up
  138. */
  139.  
  140. FreeRaster rp
  141. RemClient
  142. call closeport(portname)
  143.